package com.winz.cultureapp.adapter.xrcv;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.mine.xrecyclerview.rcvadapter.BaseRcvAdapter;
import com.mine.xrecyclerview.rcvadapter.ViewHolder;
import com.winz.cultureapp.R;
import com.winz.cultureapp.entity.CommunityListBean;

import java.util.List;

/**
 * Created by terry on 2018/1/4.
 * 文体社团
 */

public class CommunityDataAdapter extends BaseRcvAdapter<CommunityListBean.DataBean.ListBean> {

    public CommunityDataAdapter(Context context, List<CommunityListBean.DataBean.ListBean> datas, int... resid) {
        super(context, datas, resid);
    }

    @Override
    public void convert(ViewHolder holder, CommunityListBean.DataBean.ListBean data, int itemViewType) {

    }

    @Override
    public void convert(int position, ViewHolder holder, CommunityListBean.DataBean.ListBean listBean, int itemViewType) {
        super.convert(position, holder, listBean, itemViewType);
        if (itemViewType != -1){
            holder.setText(R.id.tv_title,listBean.leagueName)
                    .setText(R.id.tv_content,listBean.description)
                    .setText(R.id.tv_type,listBean.categoryName == null?listBean.leagueCategory.categoryName:listBean.categoryName)
                    .setText(R.id.tv_time,"成立时间：" + listBean.buildDate);

            //圆角处理
            Glide.with(mContext)
                    .load(listBean.imageUrl)
//                    .bitmapTransform(new RoundedCornersTransformation(mContext,16,0, RoundedCornersTransformation.CornerType.ALL))
                    .error(R.drawable.pic_default)
                    .into((ImageView) holder.getView(R.id.iv_pic));



            // 处理头尾
            if(position == 0){
                holder.getView(R.id.view_header).setVisibility(View.VISIBLE);
            }else{
                holder.getView(R.id.view_header).setVisibility(View.GONE);
            }
            if (position == mDatas.size()-1){
                holder.getView(R.id.view_bottom).setVisibility(View.GONE);
            }else {
                holder.getView(R.id.view_bottom).setVisibility(View.VISIBLE);
            }
        }
    }
}
